package entity.thread.waitNotify;

public class Cook extends Thread {

    /*
     * 判断是否有面条
     * 没有就做
     *
     * */

    public void run() {
        while (true) {
            synchronized (Desk.lock) {
                if (Desk.count == 0) {
                    break;
                }
                //没有面条就做
                if (Desk.foodFlag == 0) {
                    System.out.println("厨师做了一碗面条");
                    Desk.lock.notify();
                    Desk.foodFlag = 1;

                } else {
                    try {
                        Desk.lock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }


    }

}
